/***************************************************************************
                          utils_sndsvr.h  -  description
                             -------------------
    begin                : Tue Apr 16 2002
    copyright            : (C) 2002 by Liming Xie
    email                : liming_xie@yahoo.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _UTILS_SNDSVR_H_
#define _UTILS_SNDSVR_H_

#ifdef __cplusplus
extern "C" {
#endif

typedef struct tagSNDSVRMSG {
#define			SNDSVRMSGMAGIC		0x1234ABCD
	int			msg_magic;
	int			msg_size;

	// request
	int			device_index;
	int			mode;				// O_RDONLY, O_WRONLY, O_RDWR
	int			sample_rate;		// 8000 to 48000
	int			channels;
	// 1 for mono, 2 for stereo
	// -1 for left channel, -2 for right channel

	// response
	int			buf_size;
} SNDSVRMSG;

typedef struct tagHSNDSVR {
    	int 		fd;
	SNDSVRMSG	msg;
} HSNDSVR;

extern HSNDSVR* SNDSVR_open( int device_index, int sample_rate, int channels, int mode );

extern int SNDSVR_read( HSNDSVR* handle, void* buf, int bufsize, int tout /* micro-seconds */);

extern int SNDSVR_write( HSNDSVR* handle, void* buf, int size );

extern void SNDSVR_close( HSNDSVR* handle );

#define DEF_SNDPORT 	12345
#define DEF_PAPORT		23456

#ifdef __cplusplus
};
#endif

#endif /*  _UTILS_SNDSVR_H_ */
